﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using util;

namespace WebApplication1.studentUnion
{

    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                string checker = t2.Text;
                string score = t3.Text;
                string dormitory = t6.Text;
                int type = int.Parse(t1.Text);
                int hostel = int.Parse(t5.Text);
                string sql = "insert into checklist(type,checker,score,hostel,dormitory) values('" + type + "','" + checker +
                        "','" + score + "','" + hostel + "','" + dormitory + "');";
                MySqlHelper.GetDataTable(sql);
                Response.AddHeader("Refresh", "0");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int id = int.Parse(tid.Text);
                string sql = "delete from checklist where id = " + id;
                MySqlHelper.GetDataTable(sql);
                Response.AddHeader("Refresh", "0");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }

        protected void bin_Click(object sender, EventArgs e)
        {
            try
            {
                int id = int.Parse(tupdate.Text);
                string checker = t2.Text;
                string score = t3.Text;
                string dormitory = t6.Text;
                int type = int.Parse(t1.Text);
                int hostel = int.Parse(t5.Text);
                string sql = "update checklist set type = '" + type + "',checker = '" + checker + "',score = '" + score + "',hostel = '" + hostel +
                    "',dormitory = '" + dormitory + "' where id = " + id;
                MySqlHelper.GetDataTable(sql);
                Response.AddHeader("Refresh", "0");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }

        protected void t2_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}